<template>
  <div class="app-container">
    <div class="filter-container" id="filter-container-MhProjectInfo">
      <!-- <el-input
           v-model="listQuery.id"
           size="small"
           placeholder="ID"
           style="width: 200px; "
           class="filter-item"
           @keyup.enter.native="handleFilter"
           clearable
       />-->
      <el-input
        v-model="listQuery.projectName"
        size="small"
        placeholder="项目名称"
        style="width: 200px; "
        class="filter-item"
        @keyup.enter.native="handleFilter"
        clearable
      />
      <el-input
        v-model="listQuery.projectAddr"
        size="small"
        placeholder="项目地址"
        style="width: 200px; "
        class="filter-item"
        @keyup.enter.native="handleFilter"
        clearable
      />
      <select-option
        v-model="listQuery.status"
        size="small"
        placeholder="项目状态"
        style="width: 200px; "
        class="filter-item"
        :clearable=true
        prop-name="Status"
        :prop-ds-type=1
        prop-url="/citymh/enum/getData4AddBy"
      />
      <!--<el-input
          v-model="listQuery.projectMainUnitLinkman"
          size="small"
          placeholder="项目负责人"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-input
          v-model="listQuery.projectBasis"
          size="small"
          placeholder="项目依据"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-input
          v-model="listQuery.telephone"
          size="small"
          placeholder="联系电话"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-input
          v-model="listQuery.fundSourceCityFinacial"
          size="small"
          placeholder="市财力"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-input
          v-model="listQuery.fundSourceDistrictFinancing"
          size="small"
          placeholder="区融资"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-input
          v-model="listQuery.fundSourceDistrictFinance"
          size="small"
          placeholder="区财政"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-input
          v-model="listQuery.fundSourceOthers"
          size="small"
          placeholder="其他"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <select-option
          v-model="listQuery.categoryProject"
          size="small"
          placeholder="项目类型"
          style="width: 200px; "
          class="filter-item"
          :clearable=true
          prop-name="CategoryProject"
          :prop-ds-type=1
          prop-url="/citymh/enum/getData4AddBy"
      />
      <el-input
          v-model="listQuery.totalInvestment"
          size="small"
          placeholder="建安投资"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-date-picker
          v-model="listQuery.startTimePlan"
          type="daterange"
          value-format="yyyy-MM-dd"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="项目预计开工时间:开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          size="small"
          class="filter-item"
          clearable
      />
      <el-date-picker
          v-model="listQuery.endTimePlan"
          type="daterange"
          value-format="yyyy-MM-dd"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="项目预计完工时间:开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          size="small"
          class="filter-item"
          clearable
      />
      <el-date-picker
          v-model="listQuery.startTimeActual"
          type="daterange"
          value-format="yyyy-MM-dd"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="项目实际开工时间:开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          size="small"
          class="filter-item"
          clearable
      />
      <el-date-picker
          v-model="listQuery.endTimeActual"
          type="daterange"
          value-format="yyyy-MM-dd"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="项目实际完工时间:开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          size="small"
          class="filter-item"
          clearable
      />
      <select-option
          v-model="listQuery.investmentSupervision"
          size="small"
          placeholder="投资监理"
          style="width: 200px; "
          class="filter-item"
          :clearable=true
          prop-name="Checked"
          :prop-ds-type=1
          prop-url="/citymh/enum/getData4AddBy"
      />
      <el-date-picker
          v-model="listQuery.investmentSupervisionTime"
          type="daterange"
          value-format="yyyy-MM-dd"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="投资监理时间:开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          size="small"
          class="filter-item"
          clearable
      />
      <select-option
          v-model="listQuery.constructionSupervision"
          size="small"
          placeholder="施工监理"
          style="width: 200px; "
          class="filter-item"
          :clearable=true
          prop-name="Checked"
          :prop-ds-type=1
          prop-url="/citymh/enum/getData4AddBy"
      />
      <el-date-picker
          v-model="listQuery.constructionSupervisionTime"
          type="daterange"
          value-format="yyyy-MM-dd"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="施工监理时间:开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          size="small"
          class="filter-item"
          clearable
      />
      <el-input
          v-model="listQuery.projectMainUnit"
          size="small"
          placeholder="发起方单位"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <el-input
          v-model="listQuery.phone"
          size="small"
          placeholder="电话"
          style="width: 200px; "
          class="filter-item"
          @keyup.enter.native="handleFilter"
          clearable
      />
      <select-option
          v-model="listQuery.deleteflag"
          size="small"
          placeholder="删除标志"
          style="width: 200px; "
          class="filter-item"
          :clearable=true
          prop-name="Deleteflag"
          :prop-ds-type=1
          prop-url="/citymh/enum/getData4AddBy"
      />-->
      <el-date-picker
        v-model="listQuery.createdate"
        type="daterange"
        value-format="yyyy-MM-dd"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="创建日期:开始日期"
        end-placeholder="结束日期"
        :picker-options="pickerOptions"
        size="small"
        class="filter-item"
        clearable
      />
      <el-button :loading="queryLoading" class="filter-item" size="small" type="primary" plain icon="el-icon-search"
                 @click="handleFilter">
        查询
      </el-button>
      <!--<el-button v-if="hasDownloadBtn" :loading="downloadLoading" class="filter-item" size="small" type="primary" plain icon="el-icon-download" @click="handleDownload">
        导出报表
      </el-button>-->
      <!--      <el-button v-if="hasAddBtn" v-show="hasPermission(['mhProjectInfo:create'])" class="filter-item" size="small" type="primary" plain icon="el-icon-plus" @click="handleCreate">
              申报项目
            </el-button>-->
    </div>

    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="list"
      border
      fit
      highlight-current-row
      :show-summary="false"
      :summary-method="getSummaries"
      style="width: 100%;"
      :height="tableHeight"
      @sort-change="sortChange"
      @row-click="handleRowClick"
    >
      <!-- 行展开，显示的详细信息 -->
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <!--<el-form-item label="ID" >
                  <span>{{ props.row.id }}</span>
            </el-form-item>-->
            <el-form-item label="发起方单位">
              <span>{{ props.row.companyName }}</span>
            </el-form-item>
            <el-form-item label="项目名称">
              <span>{{ props.row.projectName }}</span>
            </el-form-item>
            <el-form-item label="项目地址">
              <span>{{ props.row.projectAddr }}</span>
            </el-form-item>
            <el-form-item label="项目负责人">
              <span>{{ props.row.projectMainUnitLinkman }}</span>
            </el-form-item>
            <el-form-item label="项目依据">
              <span>{{ props.row.projectBasis }}</span>
            </el-form-item>
            <el-form-item label="联系电话">
              <span>{{ props.row.telephone }}</span>
            </el-form-item>
            <el-form-item label="项目状态">
              <span>{{ props.row.status|getJsonName }}</span>
            </el-form-item>
            <el-form-item label="市财力">
              <span>{{ props.row.fundSourceCityFinacial }}</span>
            </el-form-item>
            <el-form-item label="区融资">
              <span>{{ props.row.fundSourceDistrictFinancing }}</span>
            </el-form-item>
            <el-form-item label="区财政">
              <span>{{ props.row.fundSourceDistrictFinance }}</span>
            </el-form-item>
            <el-form-item label="其他">
              <span>{{ props.row.fundSourceOthers }}</span>
            </el-form-item>
            <!--            <el-form-item label="项目类型" >
                          <span>{{ props.row.categoryProject|getJsonName }}</span>
                        </el-form-item>-->
            <el-form-item label="建安投资">
              <span>{{ props.row.totalInvestment }}</span>
            </el-form-item>
            <el-form-item label="项目预计开工时间">
              <span>{{ props.row.startTimePlan }}</span>
            </el-form-item>
            <el-form-item label="项目预计完工时间">
              <span>{{ props.row.endTimePlan }}</span>
            </el-form-item>
            <el-form-item label="项目实际开工时间">
              <span>{{ props.row.startTimeActual }}</span>
            </el-form-item>
            <el-form-item label="项目实际完工时间">
              <span>{{ props.row.endTimeActual }}</span>
            </el-form-item>
            <!--<el-form-item label="投资监理">
              <span>{{ props.row.investmentSupervision|getJsonName }}</span>
            </el-form-item>
            <el-form-item label="投资监理时间">
              <span>{{ props.row.investmentSupervisionTime }}</span>
            </el-form-item>-->
            <el-form-item label="施工监理">
              <span>{{ props.row.constructionSupervision|getJsonName }}</span>
            </el-form-item>
            <el-form-item label="施工监理时间">
              <span>{{ props.row.constructionSupervisionTime }}</span>
            </el-form-item>
            <el-form-item label="电话">
              <span>{{ props.row.phone }}</span>
            </el-form-item>
            <el-form-item label="创建人" >
              <span>{{ props.row.createman }}</span>
            </el-form-item>
            <el-form-item label="创建日期">
              <span>{{ props.row.createdate }}</span>
            </el-form-item>

            <el-form-item label="文件">
              <span>
                <el-image
                  v-if="props.row.fileAddress"
                  style="width: 100px; height: 100px;"
                  :src="JSON.parse(props.row.fileAddress)[0]"
                  fit="scale-down"
                  :preview-src-list="JSON.parse(props.row.fileAddress)">
                </el-image>
              </span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>



      <!--<el-table-column
        label="ID"
        prop="id"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>-->


      <el-table-column
        label="发起方单位"
        prop="companyName"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.companyName }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="项目名称"
        prop="projectName"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.projectName }}</span>
        </template>
      </el-table-column>
      <!--<el-table-column
        label="项目地址"
        prop="projectAddr"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.projectAddr }}</span>
        </template>
      </el-table-column>
-->
     <!-- <el-table-column
        label="项目负责人"
        prop="projectMainUnitLinkman"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.projectMainUnitLinkman }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="项目依据"
        prop="projectBasis"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.projectBasis }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="联系电话"
        prop="telephone"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.telephone }}</span>
        </template>
      </el-table-column>
-->
      <el-table-column
        label="项目状态"
        prop="status"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.status|getJsonName }}</span>
        </template>
      </el-table-column>

      <!--<el-table-column
        label="市财力"
        prop="fundSourceCityFinacial"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.fundSourceCityFinacial }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="区融资"
        prop="fundSourceDistrictFinancing"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.fundSourceDistrictFinancing }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="区财政"
        prop="fundSourceDistrictFinance"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.fundSourceDistrictFinance }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="其他"
        prop="fundSourceOthers"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.fundSourceOthers }}</span>
        </template>
      </el-table-column>
     --> <!--
            <el-table-column
              label="项目类型"
              prop="categoryProject"
              align="center"
              min-width="150"
              :fixed="false">
              <template slot-scope="{row}">
                <span>{{ row.categoryProject|getJsonName }}</span>
              </template>
            </el-table-column>-->

      <el-table-column
        label="建安投资"
        prop="totalInvestment"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.totalInvestment }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="项目预计开工时间"
        prop="startTimePlan"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.startTimePlan }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="项目预计完工时间"
        prop="endTimePlan"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.endTimePlan }}</span>
        </template>
      </el-table-column>

      <!--<el-table-column
        label="项目实际开工时间"
        prop="startTimeActual"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.startTimeActual }}</span>
        </template>
      </el-table-column>
-->
   <!--   <el-table-column
        label="项目实际完工时间"
        prop="endTimeActual"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.endTimeActual }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="投资监理"
        prop="investmentSupervision"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.investmentSupervision|getJsonName }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="投资监理时间"
        prop="investmentSupervisionTime"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.investmentSupervisionTime }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="施工监理"
        prop="constructionSupervision"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.constructionSupervision|getJsonName }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="施工监理时间"
        prop="constructionSupervisionTime"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.constructionSupervisionTime }}</span>
        </template>
      </el-table-column>
-->
  <!--    <el-table-column
        label="发起方单位"
        prop="projectMainUnit"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.projectMainUnit }}</span>
        </template>
      </el-table-column>
-->
    <!--  <el-table-column
        label="电话"
        prop="phone"
        align="center"
        min-width="150"
        :fixed="false">
        <template slot-scope="{row}">
          <span>{{ row.phone }}</span>
        </template>
      </el-table-column>
-->
      <!-- <el-table-column
         label="删除标志"
         prop="deleteflag"
         align="center"
         min-width="150"
         :fixed="false">
         <template slot-scope="{row}">
           <span>{{ row.deleteflag|getJsonName }}</span>
         </template>
       </el-table-column>

       <el-table-column
         label="修改日期"
         prop="modifydate"
         align="center"
         min-width="150"
         :fixed="false">
         <template slot-scope="{row}">
           <span>{{ row.modifydate }}</span>
         </template>
       </el-table-column>

       <el-table-column
         label="创建人"
         prop="createman"
         align="center"
         min-width="150"
         :fixed="false">
         <template slot-scope="{row}">
           <span>{{ row.createman }}</span>
         </template>
       </el-table-column>

       <el-table-column
         label="修改人"
         prop="modifyman"
         align="center"
         min-width="150"
         :fixed="false">
         <template slot-scope="{row}">
           <span>{{ row.modifyman }}</span>
         </template>
       </el-table-column>

       <el-table-column
         label="创建日期"
         prop="createdate"
         align="center"
         min-width="150"
         :fixed="false">
         <template slot-scope="{row}">
           <span>{{ row.createdate }}</span>
         </template>
       </el-table-column>-->


      <!--操作Button + 页面级权限控制:hasPermission -->
      <el-table-column v-if="hasEditBtn || hasDelBtn"
                       v-show="hasPermission(['mhProjectInfo:update','mhProjectInfo:delete'])" fixed="right" label="操作"
                       align="center" min-width="230">
        <template slot-scope="{row,$index}">
          <el-button v-if="hasEditBtn" v-show="hasPermission(['mhProjectInfo:update'])" type="primary" title="详细"
                     size="mini" @click="handleUpdate(row)">
            详细
          </el-button>
          <!-- <el-button v-if="hasDelBtn" v-show="row.status.id===1" type="danger" title="审核撤销" size="mini"
                      @click="handleWithDraw(row)">
             审核撤销
           </el-button>-->
          <el-button v-if="hasDelBtn" v-show="row.status.id===1" type="success"
                      title="通过" size="mini" @click="handleAgree(row)">
            通过
          </el-button>
          <el-button v-if="hasDelBtn" v-show="row.status.id===1" type="danger"
                      title="驳回" size="mini" @click="handleReject(row)">
            驳回
          </el-button>

        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"
                @pagination="getList"/>

    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
      <form-details ref="formDetails" :row="row" :isModule="true" @createResult="createResult"
                    @updateResult="updateResult"/>
      <!--      <div slot="footer" class="dialog-footer">
              <el-button @click="dialogFormVisible = false">
                取消
              </el-button>
              <el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
                审核通过
              </el-button>
            </div>-->

    </el-dialog>

    <!--BankupsAndRestore-->
    <!--<el-dialog title="审核撤销" :visible.sync="dialog4WithdrawVisible" width="30%">
      <WithdrawDialog ref="withdrawDialog" :isModule="true" :row="row" @withdrawResult="withdrawResult"/>
      <el-button type="primary" @click="withdrawAgree()">
        同意撤销
      </el-button>
      <el-button type="primary" @click="withdrawReject()">
        驳回
      </el-button>
    </el-dialog>-->

  </div>
</template>

<script>
  import { fetchList, deleteApi, updateApi } from './api'
  import waves from '@/directive/waves' // waves directive
  import { parseTime, reorgQueryParams, resizeTableHeight } from '@/utils'
  import checkPermission from '@/utils/permission'
  import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  import FormDetails from './form-details.vue' // add form form dialog
  // 从当前View的私有数据对象中取数据
  import { pickerOptions, pickerOptionsSingleDate } from './data'
  // 导入多选项组件
  import SelectOption from '@/views/coding/components/SelectOption'
  import WithdrawDialog from './withdraw-dialog-admin'

  export default {
    name: 'MhProjectInfo-List-Admin',

    components: { Pagination, FormDetails, SelectOption, WithdrawDialog },
    directives: { waves },

    props: {
      // 作为子组件时，需要回调传值；应用场景：一对多关联查询时，点击左边查询列表，传值给右边子列表，查询子列表结果
      isModule: {
        type: Boolean,
        default: false
      },
      // 当作为侧边查询结果显示的右子组件时，接收父组件的传值，watch中查询
      parentRow: Object
    },

    filters: {
      statusFilter(status) {
        const statusMap = {
          published: 'success',
          draft: 'info',
          deleted: 'danger'
        }
        return statusMap[status]
      }
    },

    data() {
      return {
        remark: '',
        fileAddress: '',
        tableKey: 0,
        btnIdList: [1, 2, 3, 4, 5],
        list: [],
        total: 0,
        footer: [],
        listLoading: false,
        queryLoading: false,
        downloadLoading: false,
        dialog4WithdrawVisible: false,
        listQuery: {
          page: 1,
          limit: 20
        },
        importanceOptions: [1, 2, 3],
        sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
        statusOptions: ['published', 'draft', 'deleted'],
        dialogFormVisible: false,
        dialogStatus: '',
        textMap: {
          update: '详细',
          create: '详细'
        },
        pickerOptions: pickerOptions,
        pickerOptionsSingleDate: pickerOptionsSingleDate,
        /*        categoryProjectList: [], // 多选项列表*/
        /*investmentSupervisionList: [], // 多选项列表*/
        constructionSupervisionList: [], // 多选项列表
        deleteflagList: [], // 多选项列表
        row: {},
        tableHeight: 0, // 表格高度
        filterContainerHeight: 0, // 查询容器高度
        clientHeight: 0 // 浏览器高度
      }
    },
    computed: {
      // button is show
      hasAddBtn() {
        if (this.btnIdList.filter(id => id === 1).length != 0) {
          return true
        }
        return false
      },
      hasEditBtn() {
        if (this.btnIdList.filter(id => id === 2).length != 0) {
          return true
        }
        return false
      },
      hasDelBtn() {
        if (this.btnIdList.filter(id => id === 3).length != 0) {
          return true
        }
        return false
      },
      hasDownloadBtn() {
        if (this.btnIdList.filter(id => id === 4).length != 0) {
          return true
        }
        return false
      }
    },

    watch: {
      // 当作为侧边查询的子组件时，接收父组件的传值，watch中查询
      parentRow(pRow) {
        this.listQuery[pRow.classInstance + 'Id'] = pRow.id // parantId, 需修改成主表ID。******
        this.handleFilter()
      }
    },

    created() {
      this.getList()
    },

    mounted() {
      // 浏览器、元素大小变化时，动态调整table高度
      resizeTableHeight(this, 'filter-container-MhProjectInfo')
    },

    methods: {
      // 页面级权限控制，调用方法如：hasPermission(['a2user:delete'])
      hasPermission(needPermisions) {
        return checkPermission(needPermisions)
      },

      withdrawAgree() {
        this.$refs['withdrawDialog'].withdrawAgree()
      },
      // 通过审核操作
      // handleAgree(row) {
      //   this.$confirm('确认通过吗？')
      //     .then(_ => {
      //       // agree api
      //       withdrawAgreeApi({ id: '' + row.id }).then((r) => {
      //         this.notify(r)
      //         if (r.success) {
      //           this.getList()
      //         }
      //       })
      //       // end
      //     })
      //     .catch(_ => {
      //     })
      // },
      withdrawReject() {
        this.$refs['withdrawDialog'].withdrawReject()
      },
      handleAgree(row) {
        this.$confirm('确认通过吗？').then(_ => {
          const param = { id: row.id }
          //项目状态改为已撤销
          param.status = 2
          updateApi(param).then((r) => {
            this.notify(r)
            if (r.success) {
              this.getList()
            }
          })
          // end
        })
          .catch(_ => {
          })

      },
      // 通过审核操作
      handleReject(row) {
        this.$confirm('确认驳回吗？').then(_ => {
          const param = { id: row.id }
          //项目状态改为已撤销
          param.status = 0
          updateApi(param).then((r) => {
            this.notify(r)
            if (r.success) {
              this.getList()
            }
          })
          // end
        })
          .catch(_ => {
          })

      },
      withdrawResult() {
        this.dialog4WithdrawVisible = false
        this.getList()
      },
      // 刷新
      getList() {
        this.queryLoading = true
        this.listLoading = true
        // 重组查询条件
        const params = Object.assign({}, this.listQuery)
        reorgQueryParams(params)
        // 查询
        fetchList(params).then(result => {
          if (!result.success) {
            this.notify(result)
            this.queryLoading = false
            this.listLoading = false
            return
          }
          this.list = result.map.rows
          this.total = result.map.total
          // footer
          if (result.map.footer && result.map.footer.length > 0) {
            this.footer = result.map.footer
          }
          this.queryLoading = false
          this.listLoading = false
          ++this.tableKey
        })
      },
      // 从第一页开始查询
      handleFilter() {
        this.listQuery.page = 1
        this.getList()
      },
      // 排序
      sortChange(data) {
        const { prop, order } = data
        if (prop === 'id') {
          this.sortByID(order)
        }
      },
      sortByID(order) {
        if (order === 'ascending') {
          this.listQuery.sort = '+id'
        } else {
          this.listQuery.sort = '-id'
        }
        this.handleFilter()
      },
      // SUM
      getSummaries(param) {
        if (this.footer.length == 0) {
          return []
        }
        const sums = []
        const { columns, data } = param
        columns.forEach((column, index) => {
          if (index === 1) {
            sums[index] = '合计'
            return
          }
          if (this.footer[0][column.property] && typeof this.footer[0][column.property] !== 'object') {
            sums[index] = this.footer[0][column.property]
            return
          }
        })
        return sums
      },
      // download excel
      handleDownload() {
        // 重组查询条件
        const params = Object.assign({}, this.listQuery)
        params.page = 1
        params.limit = 10000000
        reorgQueryParams(params)
        console.log(params)
        // 查询
        this.downloadLoading = true
        fetchList(params).then(result => {
          if (!result.success) {
            this.notify(result)
            this.downloadLoading = false
            return
          }
          import('@/vendor/Export2Excel').then(excel => {
            const tHeader = ['Id', '名称', '创建时间', '创建人']  // excel中显示的列名
            const filterVal = ['id', 'name', 'createdate', 'createman'] // excel中显示哪些列，与tHeader对应
            const list = result.map.rows
            const data = this.formatJson(filterVal, list)
            excel.export_json_to_excel({
              header: tHeader,
              data,
              filename: 'excel',
              autoWidth: true,
              bookType: 'xlsx'
            })
            this.downloadLoading = false
          })
        })
      },
      formatJson(filterVal, jsonData) {
        return jsonData.map(v => filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        }))
      },
      // 添加操作 start
      handleCreate() {
        this.dialogStatus = 'create'
        this.dialogFormVisible = true
        // 消除上次出现的验证信息
        this.$nextTick(() => {
          this.$refs['formDetails'].clearValidate()
          this.$refs['formDetails'].resetTemp()
          this.$refs['formDetails'].defaultTemp()
        })
      },
      // 调用子组件操作数据
      createData() {
        this.$refs['formDetails'].createData()
      },
      // 子组件操作成功，回调此方法，关闭弹框、刷新
      createResult() {
        this.dialogFormVisible = false
        this.handleFilter()
      },
      // 编辑操作 start
      handleUpdate(row) {
        this.row = Object.assign({}, row) // copy obj
        this.row.status = this.row.status.id // 枚举对象，取id值
        /*        this.row.categoryProject = this.row.categoryProject.id // 枚举对象，取id值*/
       /* this.row.investmentSupervision = this.row.investmentSupervision.id // 枚举对象，取id值*/
        this.row.constructionSupervision = this.row.constructionSupervision.id // 枚举对象，取id值
        this.row.deleteflag = this.row.deleteflag.id // 枚举对象，取id值
        this.dialogStatus = 'update'
        this.dialogFormVisible = true
        // 消除上次出现的验证信息
        this.$nextTick(() => {
          this.$refs['formDetails'].clearValidate()
        })
      },
      // 调用子组件操作数据
      updateData() {
        this.$refs['formDetails'].updateData()
      },
      // 子组件操作成功，回调此方法，关闭弹框、刷新
      updateResult() {
        this.dialogFormVisible = false
        this.getList()
      },
      // 删除操作
      handleDelete(row) {
        this.$confirm('确认删除吗？')
          .then(_ => {
            // delete api
            deleteApi({ id: '' + row.id }).then((r) => {
              this.notify(r)
              if (r.success) {
                this.getList()
              }
            })
            // end
          })
          .catch(_ => {
          })
      },

      // 行点击事件；应用场景：一对多关联查询时，点击左边查询列表，传值给右边子列表，查询子列表结果 xxxxxx
      handleRowClick(row, column, event) {
        // 从父组件调用此方法，进行回调下
        if (this.isModule) {
          row.classInstance = 'mhProjectInfo'
          this.$emit('input', row)
        }
      },
      getSortClass: function(key) {
        const sort = this.listQuery.sort
        return sort === `+{key}` ? 'ascending' : 'descending'
      },
      handleWithDraw(val) {
        this.row = Object.assign({}, row) // copy obj
        this.dialog4WithdrawVisible = true
      },
      insertFileResult() {
        this.dialog4WithdrawVisible = false
      }
    }
  }
</script>
<style>
  .demo-table-expand {
    font-size: 0;
  }

  .demo-table-expand label {
    width: 100px;
    color: #99a9bf;
  }

  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 40%;
  }
</style>
